EMBEDDED PROGRAMMING

W9/ASSIGNMENT

+ INDIVIDUAL ASSIGNMENT: READ A MICROCONTROLLER DATA SHEET PROGRAM YOUR BOARD TO DO SOMETHING, WITH AS MANY DIFFERENT PROGRAMMING LANGUAGES AND PROGRAMMING ENVIRONMENTS AS POSSIBLE
+GROUP ASSIGNMENT: COMPARE THE PERFORMANCE AND DEVELOPMENT WORKFLOWS FOR OTHER ARCHITECTURES 

make your own website

01 - THE BOARD DESIGN

02 - THE SCHEMATIC DESIGN

03 - PINOUT OF ATTINY44

04 - USING FABISP FOR PROGRAMING THE BOARD

05 - HOW FABISP IS CONNECTED TO MYBOARD

06 - USING ARDUINO UNO FOR PROGRAMING THE BOARD

07 - THE UPLOADED CODE

08 - THE HELLO WORLD BOARD IS WORKING

09 - SELECT ATTINY 24/44/84

10 - CHOOSE ATTINY 44 FROM THE LIST

11 - SELECT INTERNAL 8 MHZ

12 - SELECT THE PORT THAT ARDUINO IS CONNECTED TO

13 - SELECT ARDUINO AS ISP

THE PROCESS

HARDWARE AND TOOLS USED


- FabISP
- Arduino Uno
- Arduino IDE
- FTDI USB CABLE
- Wire jumpers

READING ATTINY44 THE DATA SHEET

What does Datasheet mean? Datasheets are instruction manuals for electronic components. They (hopefully) explain exactly what a component does and how to use it. Unfortunately these documents are usually written by engineers for other engineers, and as such they can often be difficult to read, especially for newcomers. Nevertheless, data-sheets are still the best place to find the details you need to design a circuit or get one working.
My background is in design and fabrication never had the chance to program any micro controllers before so this exercise was helpful and a good starting point to break into the field of micro controller programing.
For reading the data sheet of ATtiny44 I started with reading the first few pages since they give me an overview about pin-out of the micro controller and it helped me better understand the input, output and functions of each pin and the technical specifications of the chip
However, Below are some key points that I had understood from reading the data-sheets
- The ATtiny is equipped with two ports, port A (PA) and port B (PB). Port A has 8 I/O-pins (input/output) which can either be digital or analog. Port B has four I/O-pins. You can define the direction (I/O) for Port A and B via the data direction register (DDR) for the respective port, 1 will set it to output, 0 to input. By default, all pins are inputs (see page 66).
- PB3 is the dedicated RESET to restart a program or automatically reset during a program download. From the pinout, you can also retrieve information on the other pins to be used for the SPI protocol during programming (MISO - PA5, MOSI - PA6, CKOUT - PB2, VCC, GND) as well as to connect the crystal (XTAL1 and XTAL2) for an external clock. The crystal has to be connected to the XTAL pins with two 22 pF capacitor on each side (page 28).
- There are 3 types of memories in ATTiny 44 as, Data memory space and program memry space, in addition it has EEPROM memory space for storage.
And below is a list of ATtiny44 specifications :
Data Bus Width: 8 bit
Maximum Clock Frequency: 20 MHz
Program Memory Size:4 kB
Data RAM Size:256 B
Number of I/Os: 12 I/O
Supply Voltage - Max:5.5 V
Supply Voltage - Min: 2.7 V

PROGRAMING HELLO WORLD BOARD USING FABISP

For programing hello world board I decided to start with the tutorial that is listed on Fabacademy website you can access it by clicking here
First as the tutorial suggests, I had to download ATtiny support in Arduino IDE and for doing that I followed this tutorial as it was suggested by Fab Academy website.
However, After that I had powred my board using a FTDI cable while I was connecting it with the FabISP via the ISP header as shown in image #04.
I connected MISO, MOSI, SCK, RESET, VCC, and GND of the Fabisp to the corresponding pins on the hello world board .
Then, From Arduino IDE boards menu I chose Attiny 24/44/84 and from the processor menu I chose Atiny44 and I chose external 20MZH from the clock menu in addition to that I chose the port that the FabISP is connected to .
Next, I clicked on burn bootloader button and I got this massgae " Done burning bootloader "

However, after that I used the below code and uploaded it to my hello world board ( NOTE : when using FabISP as a programer you should select USBtinyISP as a programer ) And the code was uploaded successfully without any problem.

/*
This code was modified by Georges Hanna Fab Academy 2018, EMBEDDED PROGRAMMING
The code was modified Based on the below codes :

+ controlling  a servo motor by two push buttons
http://www.instructables.com/id/Servo-Controlled-by-Pushbuttons/ //

+ LED Bar Graph
https://www.arduino.cc/en/Tutorial/BarGraph


 Button

 Turns on and off a light emitting diode(LED) connected to digital pin 13,
 when pressing a pushbutton attached to pin 2.

 The circuit:
 - LED attached from pin 13 to ground
 - pushbutton attached to pin 2 from +5V
 - 10K resistor attached to pin 2 from ground

 - Note: on most Arduinos there is already an LED on the board
   attached to pin 13.

 created 2005
 by DojoDave 
 modified 30 Aug 2011
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to set pin numbers:

const int buttonPin = 3;     // the number of the pushbutton pin
const int ledPin =  7;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
 // initialize the LED pin as an output:
 pinMode(ledPin, OUTPUT);
 // initialize the pushbutton pin as an input:
 pinMode(buttonPin, INPUT);
}

void loop() {
 // read the state of the pushbutton value:
 buttonState = digitalRead(buttonPin);

 // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
 if (buttonState == HIGH) {
   // turn LED on:
   digitalWrite(ledPin, HIGH);
 } else {
   // turn LED off:
   digitalWrite(ledPin, LOW);
 }
}


PROGRAMING HELLO WORLD BOARD ARDUINO

However, I decided to use another programer for programing my board so I decided to use Arduino IDE software along with Arduino UNO as a programmer. So to do that first I had to set Arduino Uno in ISP mode.
To do that connect your Arduino Uno to the PC. Open Arduino IDE and open the ArduinoISP example file (File -> Examples -> ArduinoISP) and upload it.
Second, I had to add ATtiny44 Support to Arduino IDE. By default Arduino IDE doesn't support ATtiny44 so we should add ATtiny boards to Arduino IDE. Open File -> Preferences and in the Additional Boards Manager URLs give this link.
After opening Board Manager scroll down the list where it says "attiny by Davis A. Mellis". Click on that and install it. (as shown in image #)
After installing now you would be able to see a new entry in the Board menu. (as shown in image #)

USING ARDUINO UNO AS AN ISP PROGRAMER

To start programming the hello world board I power the it via FTDI cable I only used the VCC and GND pins in addition to that I connected the board to Arduino UNO which I was using it as an ISP programmer for programing the Attiny44 chip.
Below is the way I connected the board’s ISP pin header to the Arduino board ( Check image # 04)
VCC = VCCGND = GNS
RST = pin 10
MOSI = pin 11
MISO = pin 12
SCK = pin 13
Then after I was done with wiring the jumpers I verified and unloaded the code and everything worked correctly after many failed attempts. Few important things I learned after completing this assignment that I want to share them with you . If you want to use Arduino as an ISP always remember to do the following steps otherwise you will have problems when trying to upload the code to your microcontroller board. First, You must run and upload ArduinoISP sketch on your Arduino board before connecting Arduino to the board you intent to program . Second, Always choose Arduino port from the port list not the port that the FTDI cable is connected to otherwise Arduino will not be able to push the code to your microcontroller board.
Next, after pushing the code I unplugged all the wires from Arduino and my hello board ISP header and I just gave the board power via the FTDI USB cable and it was working perfectly as shown in video # 06

NOTE : I used the above code thet I used when programing the board with FabISP.


DOWNLOAD SECTION

+ hello_world_sketch.ino DOWNLOAD .